/**
 * Created by yihua on 2017/3/5.
 */
$(document).ready(function () {

    $(".orderdetail").each(function () {
        $(this).unbind('click').click(function () {
            var orderid = $(this).parent()[0].id
            $.ajax({
                url: '/order/getorderdetail?admin_login_type=admin',
                timeout: 100000,
                type: 'get',
                dataType: 'json',
                data: {
                    'order_id': orderid,
                },
                success: function (rs) {
                    if (rs.errno != 0) {
                        toastr.error(rs.errmsg, '', {positionClass: 'toast-bottom-center'});
                    } else {
                        fullFillOrderdetail(rs.data);
                        $("#orderdetailModal").modal('show');
                    }
                },
                error: function () {
                    toastr.error('系统错误', '', {positionClass: 'toast-bottom-center'});
                }
            });
        });
    });

    function fullFillOrderdetail(data) {
        //订单信息
        var content = '<legend>订单信息</legend>' +
            '<div class="row"><div  class="col-md-12 pull-left"><table class="table"><tbody>' +
            '<tr>' +
            '<td>订单ID:' + data.order_info.order_id + '</td>' +
            '<td>用户ID:' + data.order_info.user_id + '</td>' +
            '<td>用户名:' + data.order_info.user_name + '</td>' +
            '<td>订单状态:' + data.order_info.order_status + '</td>' +
            '</tr>' +

            '<tr>' +
            '<td>支付状态:' + data.order_info.pay_status + '</td>' +
            '<td>期望时间:' + $.myTime.UnixToDate(data.order_info.best_time, true) + '</td>' +
            '<td>支付方式ID:' + data.order_info.pay_id + '</td>' +
            '<td>支付方式:' + data.order_info.pay_name + '</td>' +
            '</tr>' +

            '<tr>' +
            '<td>商品总金额:' + data.order_info.goods_amount + '</td>' +
            '<td>配送费:' + data.order_info.shipping_fee + '</td>' +
            '<td>应付款:' + data.order_info.order_amount + '</td>' +
            '<td>已付款:' + data.order_info.money_paid + '</td>' +
            '</tr>' +

            '<tr>' +
            '<td>创建时间:' + $.myTime.UnixToDate(data.order_info.add_time, true) + '</td>' +
            '<td>确认时间:' + $.myTime.UnixToDate(data.order_info.confirm_time, true) + '</td>' +
            '<td>支付时间:' + $.myTime.UnixToDate(data.order_info.pay_time, true) + '</td>' +
            '<td>发货时间:' + $.myTime.UnixToDate(data.order_info.shipping_time, true) + '</td>' +
            '</tr>' +

            '<tr>' +
            '<td>折扣金额:' + data.order_info.discount + '</td>' +
            '<td>用户留言:' + data.order_info.remark + '</td>' +
            '<td>配送物流:' + data.order_info.shipping_partername + '</td>' +
            '<td>配送单号:' + data.order_info.shipping_no + '</td>' +
            '</tr>' +

            '<tr>' +
            '<td>配送状态:' + data.order_info.shipping_status + '</td>' +
            '<td>发票抬头:' + data.order_info.inv_payee + '</td>' +
            '<td>发票内容:' + data.order_info.inv_content + '</td>' +
            '<td>pay_fee:' + data.order_info.pay_fee + '</td>' +
            '</tr>' +
            '</tbody></table></div></div>';
        $("#detailOrder").html(content);
        /*
         //商品信息
         console.log(data.order_goods.goods_id);
         var content = '<legend>商品信息</legend>' +
         '<div class="row"><div  class="col-md-12 pull-left"><table class="table"><tbody>' +
         '<tr>'+
         '<td>订单ID:'+ data.order_goods.order_id +'</td>' +
         '<td>商品ID:'+ data.order_goods.goods_id+'</td>'+
         '<td>商品名称:'+ data.order_goods.goods_name +'</td>' +
         '<td>商品数量:'+ data.order_goods.goods_number +'</td>' +
         '</tr>'+
         '<tr>'+
         '<td>市场价格:'+ data.order_goods.market_price +'</td>' +
         '<td>商城价格:'+ data.order_goods.shop_price+'</td>'+
         '<td>规格编号:'+ data.order_goods.goods_spec_id +'</td>' +
         '<td>规格名称:'+ data.order_goods.goods_spec_name +'</td>' +
         '</tr>'+
         '<tr>'+
         '<td>是否出现:'+ data.order_goods.is_promote +'</td>' +
         '<td>是否包邮:'+ data.order_goods.is_free_shipping+'</td>'+
         '<td>特殊包装:'+ data.order_goods.is_special_packing +'</td>' +
         '<td>折扣:'+ data.order_goods.discount +'</td>' +
         '</tr>'+
         '</tbody></table></div></div>';
         $("#detailgoods").html(content);
         */
        //结算信息
        //配送地址

        $("#orderdetailModalBody").find("table").find("td").css('border', '0px');
    }


});
/*
 *
 $("#orderdetailModalBody").find("table").find("td").css('border','0px');

 */